/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package alphas.a2.util;

/**
 * 
 * @author npassaro
 */
public class ClientAuth implements IClientAuth {

	public static String Operator = "op";
	public static String IT_Manager = "it";
	public static String Shipping = "sh";

	private String host;
	private int port;

	public ClientAuth(String host, int port) {
		this.host = host;
		this.port = port;
	}

	/**
	 * Method to verify if the Order Operator user has permissions, i.e.
	 * username and password pair match.
	 * 
	 * @param username
	 *            the user login
	 * @param password
	 *            the user password
	 * @return true if the pair username/password exist in the database.
	 *         Otherwise, returns false.
	 */
	public boolean hasOperatorPermission(String username, String password) {
		VerifyUser verify = new VerifyUser();
		return verify.verify(username, password, Operator, host, port);
	}

	/**
	 * Method to verify if the IT Manager user has permissions, i.e. username
	 * and password pair match.
	 * 
	 * @param username
	 *            the user login
	 * @param password
	 *            the user password
	 * @return true if the pair username/password exist in the database.
	 *         Otherwise, returns false.
	 */
	public boolean hasITPermission(String username, String password) {
		VerifyUser verify = new VerifyUser();
		return verify.verify(username, password, IT_Manager, host, port);
	}

	/**
	 * Method to verify if the Shipping user has permissions, i.e. username and
	 * password pair match.
	 * 
	 * @param username
	 *            the user login
	 * @param password
	 *            the user password
	 * @return true if the pair username/password exist in the database.
	 *         Otherwise, returns false.
	 */
	public boolean hasShippingPermission(String username, String password) {
		VerifyUser verify = new VerifyUser();
		return verify.verify(username, password, Shipping, host, port);
	}
}
